package com.woniuxy.handler;

import com.woniuxy.service.MoneyHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 〈一句话功能简述〉<br>
 * 〈流水账单handler〉
 *
 * @author jia
 * @create 2019/9/27
 * @since 1.0.0
 */
@RestController
@RequestMapping("/money")
public class MoneyHistoryHandler {

    @Autowired
    MoneyHistoryService MoneyHistoryService;

    //最近7天收入
    @RequestMapping("/history")
    public List<Map> findAll(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String d = sdf.format(date);
        List<Map> mapList = MoneyHistoryService.selectMoneyByDay(d);
        return mapList;
    }
    //类型数据
    @RequestMapping("/type")
    public List<Map> findByType(){
        Map<String,String> map = new HashMap<>();
        List<Map> mapList = new ArrayList<>();
//        map.put("value","123");
//        map.put("name","手续费");
//        mapList.add(map);
//        mapList.add(map);
//        Map<String,String> map1 = new HashMap<>();
//        map1.put("value","123");
//        map1.put("name","违约金");
//        mapList.add(map1);
//        mapList.add(map1);
        mapList= MoneyHistoryService.selectMoneyByType();
        System.out.println(mapList);
        return mapList;
    }
}
